package homeWork;

import java.util.Random;
import java.util.Scanner;

public class GenRandNumber {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你想生成随机数的最小值：");
        int min = scanner.nextInt();
        System.out.println("请输入你想生成随机数的最大值：");
        int max = scanner.nextInt();
        GenRandNumber gen = new GenRandNumber(); //新建GenRandNumber类的实例对象
        int result = gen.genRandNum(min, max); //调用GenRandNumber实例对象的genRandNum()方法
        System.out.printf("你要求的随机数已生成，结果是:%d", result);
    }

    public int genRandNum(int min, int max) {
        // 请在这里完善你的代码
        Random rm = new Random();
        return rm.nextInt(min + max + 1) + min;
    }
}